		<%@page import="com.itextpdf.text.log.SysoLogger"%>
<%@ page pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="fr.esgi.donnees.Database"%>
<%@ page import="fr.esgi.classes.Projet"%>
<%@ page import="fr.esgi.classes.Livrable"%>
<%@ page import="fr.esgi.utils.Repertoire"%>
<%
	String uid=String.valueOf(session.getAttribute("uid"));
	ArrayList<Projet> list;
	ArrayList<Livrable> listLivrable;
	//ArrayList<Repertoire> listLivrable;
	Database c = new Database();
	//Repertoire r =new Repertoire();
	list = c.afficherProjetEtudiant(uid);
	listLivrable = c.afficherLivrable();
	String projet=request.getParameter("projet");
	String livrable=request.getParameter("livrable");
//	String []listRepertoire=r.listFiles(projet,livrable);
//String []listRepertoire=r.listFiles(String.valueOf(listLivrable.get(0).getIdProjet()),String.valueOf(listLivrable.get(0).getIdLivrable()));
%>
<!DOCTYPE html>
<html>
<head>
<title>Rendre un projet</title>

<script language="JavaScript" type="text/javascript">
		function del(file){
				var idprojet=selectElmt.options[selectElmt.selectedIndex].value;
				var idlivrable=selectElmt.options[selectElmt.selectedIndex].value;
				window.location.href="DeleteFile.jsp?idprojet="+idprojet+"&idlivrable="+idlivrable+"&file="+file;
			}
			function griser() {
				var Obj = document.getElementById('livrable'); 
 				Obj.innerHTML = "";
 				var selectElmt = document.getElementById("projet");
 				var test=selectElmt.options[selectElmt.selectedIndex].value;
 				var colIdProjet=new Array();
				var colIdLivrable=new Array();
 				var colNomLivrable=new Array();
 				<%for (int i=0; i<listLivrable.size(); i++) {%>
						colIdProjet[<%=i%>] = "<%=listLivrable.get(i).getIdProjet()%>"; 
  						colIdLivrable[<%=i%>] = "<%=listLivrable.get(i).getIdLivrable()%>"; 
  						colNomLivrable[<%=i%>] = "<%=listLivrable.get(i).getNom()%>";
		<%}%>
	for ( var j = 0; j < colIdProjet.length; j++) {
			if (test == colIdProjet[j]) {
				var opt = document.createElement("option");
				document.getElementById("livrable").options.add(opt);
				opt.text = colNomLivrable[j];
				opt.value = colIdLivrable[j];
			}
		}
	}
</script>
<%@ include file="/jsp/design/header.jsp"%>
<%@ include file="/jsp/design/menu.jsp"%>
</div>
<div class="bd">
	<div id="page">

		<!-- MAIN COLUMN -->
		<div id="main">
			<div class="content">
<body>



	<form name="ValidationUpload" action="ValidationUpload" method="post"
		enctype="multipart/form-data">
		<%
			if (list.size() == 0) {
				out.println("vous n'avez pas de projet en cours");
			} 
			else {
		%>
		<p>
			Projet<select id="projet" name="projet" onchange="griser();">
				<%
					for (int i = 0; i < list.size(); i++) {
				%>
				<option value="<%out.print(list.get(i).getId());%>">
					<%
						out.println(list.get(i).getNom());
					%>
				</option>
				<%
				}
				
			%>
			</select>
			<% for (int i = 0; i < listLivrable.size(); i++) { 
			 	if(i==0){%>
					Livrable <select name="livrable" id="livrable">
				<% }
				if(list.get(0).getId()==listLivrable.get(i).getIdProjet()){
							
			%>
			<option value="<%out.print(listLivrable.get(i).getIdLivrable());%>">
					<%
						out.println(listLivrable.get(i).getNom());
					%>
			</option>
			<%} }%>
			</select>
		</p>
		<center>
			<table border="2">
				<tr>
					<td align="center"><b>Envoyer ses fichiers</td>
				</tr>
				<tr>
					<td>Specify file: <input name="file" type="file" id="file">
					<td>
				</tr>
				<tr>
					<td>Specify file:<input name="file" type="file" id="file">
					</td>
				</tr>
				<tr>
					<td>Specify file:<input name="file" type="file" id="file">
					</td>
				</tr>
				<tr>
					<td>Specify file:<input name="file" type="file" id="file">
					</td>
				</tr>
				<tr>
					<td>Specify file:<input name="file" type="file" id="file">
					</td>
				</tr>
				<tr>
					<td>Specify file:<input name="file" type="file" id="file">
					</td>
				</tr>
				<tr>
					<td align="center"><input type="submit" name="Submit"
						value="valider les fichier" /></td>
				</tr>
			</table>
	</form>
	<%}%>
</body>
				<%@ include file="/jsp/design/footer.jsp"%>
